package com.kit.data.kitopeso.adapter;

import android.annotation.SuppressLint;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.kit.data.kitopeso.R;
import com.kit.data.kitopeso.base.BaseBindingAdapter1;
import com.kit.data.kitopeso.databinding.KitoCsItemBinding;
import com.kit.data.kitopeso.obj.KitoCustomerService;
import com.kit.data.kitopeso.tools.ResUtils;
import com.kit.data.kitopeso.tools.ViewUtils;

import java.util.List;

public class CustomerServiceAdapter extends BaseBindingAdapter1<KitoCustomerService, KitoCsItemBinding> {


    public CustomerServiceAdapter(List<KitoCustomerService> dataList) {
        super(dataList);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void bindData(KitoCsItemBinding binding, KitoCustomerService item, int position) {

        binding.tvSubTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);

        if (item.isPhone()) {
            binding.tvTitle.setText(ResUtils.s(R.string.cs_item_title1));
            binding.tvBtn.setText(ResUtils.s(R.string.cs_item_btn1));
            binding.tvBtn.setVisibility(View.VISIBLE);
        } else {
            binding.tvTitle.setText(ResUtils.s(R.string.cs_item_title2));
            binding.tvBtn.setVisibility(View.GONE);
        }
        binding.tvBtn.setOnClickListener(v -> {
            ViewUtils.viewScale(v);
            if (onBtnItemClickListener != null) {
                onBtnItemClickListener.onItemClick(position);
            }
        });
        binding.tvSubTitle.setText(item.getData());

    }

    @Override
    protected int getItemType(KitoCustomerService item) {
        return 0;
    }

    @Override
    protected KitoCsItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return KitoCsItemBinding.inflate(inflater, parent, false);
    }


}
